/*
 * @author dai.dv
 * @version $Id: ThreadAlive.java 98 2010-08-26 05:33:10Z  $
 */

package snippet.theory2;

/**
 * Thread
 * @author dai.dv
 */
public class ThreadAlive implements Runnable{
    /**
     * Thread entity
     */
    Thread t;

    /**
     * constructor
     */
    public ThreadAlive() {
        t = new Thread(this);
        System.out.println("Start thread.");
        System.out.println(t.isAlive());
        t.start();
    }
   
    /**
     * Implement method
     * @author dai.dv
     */
    public void run() {
        System.out.println("Thread is running.");
        //throw new UnsupportedOperationException("Not supported yet.");
    }
}

/**
 * Main
 * @author dai.dv
 */
class ThreadDemo {

    /**
     * Constructor
     */
    public ThreadDemo() {
        //init 1 thread
        ThreadAlive ta = new ThreadAlive();
    }


    /**
     * Main
     * @author dai.dv
     * @param String args
     */
    public static void main(String[] args) {
        //init ta
        new ThreadDemo();

        //init th
        ThreadAlive th = new ThreadAlive();
        System.out.println(th.t.isAlive());

        th.t.stop();
        System.out.println(th.t.isAlive());

        th.t.resume();
        System.out.println(th.t.isAlive());
    }


}